﻿@using TS2015.Models;
@{
    AjaxOptions aj = new AjaxOptions
    {
        InsertionMode = InsertionMode.Replace,
        UpdateTargetId = "content-main",
        LoadingElementId = "loading-icon",
        OnFailure = "AjaxFailure",
        OnBegin = "AjaxBegin",
        OnComplete = "AjaxComplete"
    };
    //TS2015Context db = new TS2015Context();
    //List<TS2015.Models.TbChucNang> menuList = db.TbChucNangs.ToList();
}

<aside class="sidebar offscreen-left">

    <nav id="main-navigation" class="main-navigation" data-height="auto" data-size="6px" data-distance="0" data-rail-visible="true" data-wheel-step="10">
      
            <ul class="nav mb20">

                <li>

                    @Ajax.ActionLink("Trang đầu", "Index", "Home", aj)
                </li>
                <li>
                    <a href="/Home">
                        <i class="glyphicon glyphicon-globe"></i>
                        <span>Trang chủ</span>
                    </a>
                </li>
                <li>
                    <a href="javascript:;">
                        <i class="glyphicon glyphicon-chevron-down toggle-accordion"></i>
                        <i class="glyphicon glyphicon-user"></i>
                        <span>Quản lý Thí sinh</span>
                    </a>
                    <ul class="sub-menu">
                        <li>
                            @Ajax.ActionLink("Danh sách Thí sinh", "CandidateList", "CandidateManagement", aj)
                        </li>
                        <li>
                            @Ajax.ActionLink("Đăng ký hồ sơ", "SelectTrainingSystem", "CandidateManagement", aj)
                        </li>
                        <li>
                            <a href="#">
                                <span>Thu lệ phí</span>
                            </a>
                        </li>
                        <li>
                            <a href="#">
                                <span>Thí sinh tuyển thẳng</span>
                            </a>
                        </li>
                    </ul>
                </li>
                <li>
                    <a href="javascript:;">
                        <i class="toggle-accordion glyphicon glyphicon-chevron-down"></i>
                        <i class="glyphicon glyphicon-home"></i>
                        <span>Quản lý Trường học</span>
                    </a>
                    <ul class="sub-menu">
                        <li>
                            @Ajax.ActionLink("Trường THPT", "HighSchool", "HighSchoolManagement", aj)
                        </li>
                        <li>
                            @Ajax.ActionLink("Trường Đại học", "University", "HighSchoolManagement", aj)
                        </li>
                    </ul>
                </li>
                <li>
                    <a href="javascript:;">
                        <i class="toggle-accordion glyphicon glyphicon-chevron-down"></i>
                        <i class="glyphicon glyphicon-list-alt"></i>
                        <span>Quản lý đăng ký</span>
                    </a>

                    <ul class="sub-menu">
                        <li>
                            @Ajax.ActionLink("Hệ đào tạo", "TrainingSystem", "RegistrationManagement", aj)
                        </li>
                        <li>
                            @Ajax.ActionLink("Khoa", "Department", "RegistrationManagement", aj)
                        </li>
                        <li>
                            @Ajax.ActionLink("Ngành", "Phylum", "RegistrationManagement", aj)
                        </li>

                        <li>
                            @Ajax.ActionLink("Chuyên ngành", "Major", "RegistrationManagement", aj)
                        </li>
                        <li>
                            @Ajax.ActionLink("Khối thi", "Group", "RegistrationManagement", aj)
                        </li>
                        <li>
                            @Ajax.ActionLink("Khu vực", "Area", "RegistrationManagement", aj)
                        </li>

                        <li>
                            @Ajax.ActionLink("Dân tộc", "Ethnic", "RegistrationManagement", aj)
                        </li>

                        <li>
                            @Ajax.ActionLink("Tỉnh", "Province", "RegistrationManagement", aj)
                        </li>
                        <li>
                            @Ajax.ActionLink("Huyện", "Commune", "RegistrationManagement", aj)
                        </li>
                        <li>
                            @Ajax.ActionLink("Đối tượng ưu tiên", "PriorityGroup", "RegistrationManagement", aj)
                        </li>
                        <li>
                            @Ajax.ActionLink("Môn tốt nghiệp", "GraduateSubject", "RegistrationManagement", aj)
                        </li>
                        <li>
                            @Ajax.ActionLink("Môn thi - Khối thi", "GraduateSubject_Group", "RegistrationManagement", aj)
                        </li>
                    </ul>
                </li>

                <li>
                    <a href="javascript:;">
                        <i class="glyphicon glyphicon-search"></i>
                        <i class="toggle-accordion glyphicon glyphicon-chevron-down"></i>
                        <span>Tìm kiếm</span>
                    </a>
                    <ul class="sub-menu">
                        <li>
                            @Ajax.ActionLink("Tìm kiếm thí sinh", "SearchCandidate", "Search", aj)
                        </li>
                        <li>
                            @Ajax.ActionLink("Tìm kiếm Trường THPT", "SearchHighSchool", "Search", aj)

                        </li>
                        <li>
                            @Ajax.ActionLink("Tìm kiếm Trường Đại học", "SearchUniversity", "Search", aj)
                        </li>

                    </ul>
                </li>
                <li>
                    <a href="javascript:;">
                        <i class="toggle-accordion glyphicon glyphicon-chevron-down"></i>
                        <i class="glyphicon glyphicon-stats"></i>
                        <span>Thống kê</span>
                    </a>
                    <ul class="sub-menu">
                        <li>
                            @Ajax.ActionLink("Lượng đăng ký Hồ sơ", "HoSoDangKy", "ThongKe", aj)
                        </li>
                        <li>
                            @Ajax.ActionLink("Hồ sơ theo Hệ đào tạo", "DangKyTheoHDT", "ThongKe", aj)
                        </li>
                        <li>
                            @Ajax.ActionLink("Hồ sơ theo Khối thi", "DangKyTheoKhoiThi", "ThongKe", aj)
                        </li>
                        <li>
                            @Ajax.ActionLink("Hồ sơ theo Ngành", "DangKyTheoNganh", "ThongKe", aj)
                        </li>
                        <li>
                            @Ajax.ActionLink("Hồ sơ theo Chuyên ngành", "DangKyTheoChuyenNganh", "ThongKe", aj)
                        </li>
                    </ul>
                </li>
            
                <li>
                    <a href="javascript:;">
                        <i class="toggle-accordion glyphicon glyphicon-chevron-down"></i>
                        <i class="glyphicon glyphicon-stats"></i>
                        <span>Quản trị trang</span>
                    </a>
                    <ul class="sub-menu">
                        <li>
                            @Ajax.ActionLink("Tin tức", "DanhSachTinTuc", "QuanTriTrang", aj)
                        </li>
                        <li>
                            @Ajax.ActionLink("Thêm tin tức", "ThemHoacSuaTinTuc", "QuanTriTrang", aj)
                        </li>
                        <li>
                            @Ajax.ActionLink("Thể loại", "TheLoaiTinTuc", "QuanTriTrang", aj)
                        </li>
                        <li>
                            <a href="#">
                                <span>Slide</span>
                            </a>
                        </li>
                    </ul>
                </li>

                <li>
                    <a href="javascript:;">
                        <i class="toggle-accordion glyphicon glyphicon-chevron-down"></i>
                        <i class="glyphicon glyphicon-cog"></i>
                        <span>Quản lý Tài khoản</span>
                    </a>
                    <ul class="sub-menu">
                        <li>
                            @Ajax.ActionLink("Danh sách Quyền", "Acting", "AccoutManagement", aj)
                        </li>
                        <li>
                            @Ajax.ActionLink("Chức năng", "Funtion", "AccoutManagement", aj)
                        </li>
                        <li>
                            @Ajax.ActionLink("Danh sách Tài khoản", "ListAccout", "AccoutManagement", aj)
                        </li>
                        <li>
                            @Ajax.ActionLink("Máy chủ mail","Index","QLHeThong",aj)
                        </li>
                        <li>
                            @Ajax.ActionLink("Gửi mail", "SendMail", "QLHeThong", aj)
                        </li>
                    </ul>
                </li>

            </ul>
       @*@{int quyen = int.Parse(Session["Quyen"].ToString());}
       @if (db.TbChucNang_Quyen.Where(m => m.MaQuyen == quyen).Count() == 0)
       {
           Response.Redirect("~/Home/Login");
       }*@
        @*<ul class="nav mb20">
            <li>

                @Ajax.ActionLink("Trang đầu", "Index", "Home", aj)
            </li>
            <li>
                <a href="/Home">
                    <i class="glyphicon glyphicon-globe"></i>
                    <span>Trang chủ</span>
                </a>
            </li>
            
            @foreach (var mp in menuList.Where(p => p.MaCNCha == 0 && p.TrangThai == 1))
            {
                var ListActing = db.TbChucNang_Quyen.Where(m => m.MaCN == mp.MaCN);
                foreach (var item in ListActing)
                {
                    if (item.MaQuyen == int.Parse(Session["Quyen"].ToString()))
                    {
                        <li>
                            <a href="javascript:;">
                                <i class="toggle-accordion glyphicon glyphicon-chevron-down"></i>
                                <i class="@mp.CssIcon"></i>
                                <span>@mp.TenCN</span>
                            </a>
                            @if (menuList.Count(p => p.MaCNCha == mp.MaCN) > 0)
                            {
                                @:<ul class="sub-menu">
                            }

                            @RenderMenuItem(menuList, mp,db,aj)

                            @if (menuList.Count(p => p.MaCNCha == mp.MaCN) > 0)
                            {
                                @:</ul>
                            }
                        </li>
                    }
                }
            }
        </ul>

        @helper RenderMenuItem(List<TS2015.Models.TbChucNang> menuList, TS2015.Models.TbChucNang mi,TS2015Context db,AjaxOptions aj)
        {
            //AjaxOptions aj = new AjaxOptions
            //{
            //    InsertionMode = InsertionMode.Replace,
            //    UpdateTargetId = "content-main",
            //    LoadingElementId = "loading-icon",
            //    OnFailure = "AjaxFailure",
            //    OnBegin = "AjaxBegin",
            //    OnComplete = "AjaxComplete"
            //};
            //TS2015Context db = new TS2015Context();

            foreach (var cp in menuList.Where(p => p.MaCNCha == mi.MaCN && p.TrangThai == 1))
            {
                string Action, Controller;
                if (!cp.Link.Contains("/"))
                {
                    continue;
                }
                var ListActing = db.TbChucNang_Quyen.Where(m => m.MaCN == cp.MaCN);
                foreach (var item in ListActing)
                {
                    if (item.MaQuyen == int.Parse(Session["Quyen"].ToString()))
                    {
                        string[] Link = cp.Link.TrimEnd().Split('/');
                        Action = Link[0].ToString().TrimEnd();
                        Controller = Link[1].ToString().TrimEnd();
                        @:<li>
                        @Ajax.ActionLink(cp.TenCN, Action, Controller, aj);
                        @*<span>@cp.TenCN</span>*@
                        @*if (menuList.Count(p => p.MaCNCha == cp.MaCN) > 0)
                            {
                                @:<ul>
                            }
                            @RenderMenuItem(menuList, cp,db,aj)
                            if (menuList.Count(p => p.MaCNCha == cp.MaCN) > 0)
                            {
                                @:</ul>
                            }
                            else
                            {
                                @:</li>
                            }
                        }
                    }

                }
    } *@
</nav>
</aside>